package com.crx.springbootinit.utils;

public class ConstellationUtils {

    private final static int[] dayArr = new int[] { 20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22 };
    private final static String[] constellationArr = new String[] {
            "摩羯座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座",
            "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座"
    };

    /**
     * 根据月份和日期获取星座
     * @param month 月份（1-12）
     * @param day 日期（1-31）
     * @return 对应的星座名称
     * @throws IllegalArgumentException 如果月份或日期无效
     */
    public static String getConstellation(int month, int day) {
        if (month < 1 || month > 12) {
            throw new IllegalArgumentException("月份必须在 1 到 12 之间");
        }
        if (day < 1 || day > 31) {
            throw new IllegalArgumentException("日期无效");
        }
        return day < dayArr[month - 1] ? constellationArr[month - 1] : constellationArr[month];
    }
}

